﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnPremiseProductService
{
    public class HelliumService : IHelliumService
    {
        string[] productnames = new string[] { "Tea", "Milk", "Water", "Sugar", "Coffee", "Patties", "Plain Rice", "Dal", "Sambar", "Idli", "Bada", "Pakoda", "Bread", "Sandwitch", "Hot Dog", "Burger", "Roti", "Paratha" };
        public HelliumResponse<string> Execute(HelliumRequest<string> command)
        {
            Console.WriteLine("You are in Execute");
            string result = "Your command " + command + " served at " + DateTime.Now + " at " + Environment.MachineName;
            return new HelliumResponse<string>() { Body = result };
        }

        public IEnumerable<Product> GetProducts(string category)
        {
            Console.WriteLine("You are in GetProducts");
            List<Product> products = new List<Product>(); 
            Random rand = new Random();
            for (int i = 0; i < 10; i++)
            {
                Product p = new Product()
                {
                    Category = category,
                    Price = (float)(rand.NextDouble() * i * 20),
                    ProductName = productnames[i],
                    Qantity = rand.Next(15)
                };
                products.Add(p);
            }
            return products ;
        }


        public string Ping(string message)
        {
            Console.WriteLine("You are in Ping");
            return "Reply from Server " + message;
        }
    }
}
